package net.hn.hnms.biz.common.activiti.builder;


import net.hn.hnms.biz.common.activiti.result.DeployResult;
import net.hn.hnms.biz.common.activiti.service.ProcessApiService;

import java.util.List;

/**
 * Created on 2022/8/5.
 *
 * @author ly
 * @desc: 流程定义信息查询构造
 */
public class ProcessDefinitionQuery {

    //流程名称
    private String processName;

    //版本
    private Integer version;

    //是否暂停
    private boolean suspended;
    private ProcessApiService processApiService;

    private ProcessDefinitionQuery() {
    }

    public ProcessDefinitionQuery(ProcessApiService processApiService) {
        this.processApiService = processApiService;
    }

    public ProcessDefinitionQuery processName(String processName) {
        this.processName = processName;
        return this;
    }

    public ProcessDefinitionQuery version(Integer version) {
        this.version = version;
        return this;
    }

    public ProcessDefinitionQuery businessKey(boolean suspended) {
        this.suspended = suspended;
        return this;
    }

    /**
     * 查询流程定义信息集合
     * @return List<DeployResult> 流程定义信息集合
     */
    public List<DeployResult> query() {
        return processApiService.processDefinitionList(this.processName, this.version, this.suspended);
    }
}
